package cn.shangtour.scenery.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import cn.shangtour.common.pojo.Scenery;
import cn.shangtour.common.vo.SceneryResult;
import cn.shangtour.common.vo.SceneryUIResult;
import cn.shangtour.scenery.service.SceneryService;

@RestController
@RequestMapping("/scenery/manage/")
//景点查询
public class SceneryController {
	@Autowired
	private SceneryService sceneryService;
	@RequestMapping("/pageManage")
	public SceneryUIResult sceneryPageQuery(Integer page,Integer rows){
		SceneryUIResult result = sceneryService.sceneryPageQuery(page,rows);
		return result;
	}
//单景点查询
	@RequestMapping("/item/{sceneryId}")
	public Scenery queryById(@PathVariable String sceneryId){
		Scenery scenery = sceneryService.queryById(sceneryId);
		return scenery;
	}
//新增景点
	@RequestMapping("save")
	public SceneryResult scenerySave(Scenery scenery){
		try {
			sceneryService.scenerySave(scenery);
			return SceneryResult.ok();
		} catch (Exception e) {
			e.printStackTrace();
			return SceneryResult.build(201,e.getMessage(),null);
		}
	}
//景点更新
	@RequestMapping("update")
	public SceneryResult sceneryUpdate(Scenery scenery){
		try {
			sceneryService.sceneryUpdate(scenery);
			return SceneryResult.ok();
		} catch (Exception e) {
			e.printStackTrace();
			return SceneryResult.build(201,e.getMessage(),null);
		}
	}
}





